package com.scpii.api.common.auth.token;

import com.scpii.api.common.auth.AuthorizationRequest;
import com.scpii.api.common.auth.client.ClientDetailsService;

public class RefreshTokenGranter extends AbstractTokenGranter {

	public static final String GRANT_TYPE = "refresh";

	public RefreshTokenGranter(AuthorizationServerTokenServices tokenServices,
			ClientDetailsService clientDetailsService) {
		super(tokenServices, clientDetailsService, GRANT_TYPE);
	}

	@Override
	protected AuthAccessToken getAccessToken(
			AuthorizationRequest authorizationRequest) {
		String refreshToken = authorizationRequest.getAuthorizationParameters()
				.get("refreshToken");
		return getTokenServices().refreshAccessToken(refreshToken,
				authorizationRequest);
	}

}